<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>插槽编译作用域基础</title>
</head>
<body>
<div id="app">
    <cpn></cpn>
    <hr>
    <cpn>
        <template v-slot:cpn>
            <button>abc</button>
        </template>
    </cpn>
    <hr>
    <cpn>
        <!--  scope 是一个对象类型，用来存储由具名插槽 cpn 传递过来的数据。  -->
        <template v-slot:cpn="scope">
            <!--<div>{{ scope }}</div>-->
            <div>{{ scope.info }}</div>
        </template>
    </cpn>
</div>

<template id="cpn">
    <h1>世界，您好！</h1>
    <!--  通过 name 属性命名插槽的名称， 提供自定义属性的形式提供数据  -->
    <!--<slot name="cpn" info="Hello, World!"><span>Hello，World</span></slot>-->
    <slot name="cpn" v-bind:info="info"><span>Hello，World</span></slot>
    <h1>欢迎来到陕西交通职业技术学院！</h1>
</template>

<script type="module">
    import {createApp, ref} from "../../../../js/vue.esm-browser.js";
    import {defineComponent} from "../../../../js/vue.esm-browser.js";

    let cpn = defineComponent(
        {
            template: "#cpn",
            setup(){
                let info = ref("Hello, Vue!")

                return {
                    info,
                }
            }
        }
    );

    let app = createApp(
        {
            setup() {

            },
            components: {
                cpn,
            }
        }
    )

    app.mount("#app")
</script>
</body>
</html>